package com.poetize.plus.entity.vo;

import com.poetize.plus.entity.po.Menu;
import io.swagger.v3.oas.annotations.media.Schema;

/**
 * @author zuosy
 * @created 2024/3/29 15:00
 */
public record MenuVO(
        @Schema(description = "id")
        Long id,
        @Schema(description = "父菜单id")
        Long parentId,
        @Schema(description = "菜单分区（0：后端，1：门户）")
        String partition,
        @Schema(description = "菜单名称")
        String name,
        @Schema(description = "排序")
        Integer sort,
        @Schema(description = "路由地址")
        String path,
        @Schema(description = "菜单图标")
        String icon,
        @Schema(description = "组件路径")
        String component,
        @Schema(description = "组件名")
        String componentName,
        @Schema(description = "是否禁用")
        Boolean visible
) {

        /**
         * 实体类转vo
         * @param menu
         * @return
         */
        public static MenuVO convert(Menu menu){
                return new MenuVO(
                        menu.getId(),
                        menu.getParentId(),
                        menu.getPartition(),
                        menu.getName(),
                        menu.getSort(),
                        menu.getPath(),
                        menu.getIcon(),
                        menu.getComponent(),
                        menu.getComponentName(),
                        menu.getVisible());
        }
}
